package com.example.demo.common.config;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;

public class CustomPasswordEncoder implements PasswordEncoder {

    private static final String SITE_WIDE_SECRET = "hzz-demo-secret-key";
    private static final PasswordEncoder encoder = new Pbkdf2PasswordEncoder(SITE_WIDE_SECRET);

    @Override
    public String encode(CharSequence rawPassword) {
        return encoder.encode(rawPassword);
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encoder.encode(rawPassword).equalsIgnoreCase(encodedPassword);
    }
}
